package org.seckill.test;


import com.mchange.v2.c3p0.DataSources;
import org.apache.ibatis.datasource.pooled.PooledDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;



/**
 * @Author: JLL
 * @Date: 2019/12/13 0:45
 */
public class C3p0Test2 {


    public static void main(String[] args) throws SQLException {

        //这是工厂类拿到 连接池
        DataSource ds_unpooled = DataSources.unpooledDataSource("jdbc:mysql://localhost:3306/db1",
                "root",
                "root");


//        DataSource ds_pooled = DataSources.pooledDataSource( ds_unpooled );
        Map overrides = new HashMap();
        overrides.put("maxStatements", "200");         //Stringified property values work
        overrides.put("maxPoolSize", new Integer(50)); //"boxed primitives" also work
        DataSource ds_pooled = DataSources.pooledDataSource( ds_unpooled ,overrides);
        Connection connection = ds_pooled.getConnection();
//        PooledDataSource  pooledDataSource  = (PooledDataSource)DataSources.pooledDataSource( ds_unpooled ,overrides);
//        Connection connection = pooledDataSource.unwrapConnection();


        System.out.println(connection);
        connection.close();



    }
}
